package com.wang.controller;

import com.wang.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * @Classname HelloController
 * @Description TODO
 * @Date 2024/5/13 10:50
 * @Created by pc
 */
@Controller
public class HelloController {
    @RequestMapping("/hello")
    public String hello(ModelMap map){
        map.addAttribute("msg","123");
        return "index";// 逻辑视图名
    }


    @RequestMapping("/index")
    public String index(ModelMap map){
        map.addAttribute("msg","后台过来的msg~~~");
        map.addAttribute("age",20);
        List<Integer> list = Arrays.asList(11, 22, 33, 44, 55);
        map.addAttribute("list",list);
        User u1 = new User("张三","123","男",20,new Date(), LocalDate.now());
        User u2 = new User("李四","123","男",20,new Date(), LocalDate.now());
        User u3 = new User("王五","123","男",20,new Date(), LocalDate.now());
        User u4 = new User("赵六","123","男",20,new Date(), LocalDate.now());
        List<User> userList = Arrays.asList(u1, u2, u3, u4);
        map.addAttribute("userList",userList);
        return "index";// 逻辑视图名
    }



}
